package com.xuqm.sdhbwfu.app.ui

import android.content.Intent
import android.os.Bundle
import com.xuqm.base.common.ToolsHelper
import com.xuqm.base.ui.BaseActivity
import com.xuqm.sdhbwfu.app.R
import com.xuqm.sdhbwfu.app.databinding.ActivityAddObjBinding

class PmAddObjActivity : BaseActivity<ActivityAddObjBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_add_obj

    override fun fullscreen(): Boolean = true

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        binding.confirm.setOnClickListener {
            val code = binding.code.text.toString()
            val name = binding.name.text.toString()
            if (code.isEmpty()
                || name.isEmpty()
            ) {
                ToolsHelper.showMessage("填写项不能为空")
                return@setOnClickListener
            }

            setResult(RESULT_OK, Intent().apply {
                putExtra("name", name)
                putExtra("code", code)
            })
            finish()
        }
        binding.cancel.setOnClickListener {
            setResult(RESULT_CANCELED)
            finish()
        }
    }

}